var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("EventData"),
    a = t("GameData"),
    i = t("OnClick"),
    s = t("Util"),
    c = t("View"),
    l = t("Util"),
    u = t("fightManager"),
    p = t("Platforms"),
    f = t("BootConst"),
    d = t("ConfS"),
    h = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (
                (e.res = "guide"),
                (e.zIndex = 5),
                (e.isDestroy = !0),
                (e.group = "guide"),
                (e.set引导数据 = new r.default(null)),
                e
            );
        }
        return (
            n(e, t),
            (e.prototype.onEnable = function () {
                (e.isRuning = !0),
                    (cc.find("Canvas/GuideCamera").active = !0),
                    (this.透明背景 = this.find("透明背景")),
                    (this.黑色遮罩 = this.find("黑色遮罩")),
                    (this.按钮 = this.find("按钮")),
                    (this.双倍按钮 = this.find("双倍按钮")),
                    (this.拖动按钮 = this.find("拖动按钮")),
                    (this.人物 = this.find("人物")),
                    (this.对话框 = this.find("对话框")),
                    (this.手 = this.find("手")),
                    (this.对话框文字 = this.find("对话框/Label").getComponent(cc.Label)),
                    this.set引导数据.on(this, this.on引导数据);
            }),
            (e.prototype.onDisable = function () {
                (e.isRuning = !1), (cc.find("Canvas/GuideCamera").active = !1);
            }),
            (e.prototype.update = function (t) {
                this.state && this.state.onUpdate(t);
            }),
            (e.prototype.onClick = function (t) {
                this.state && this.state.onClick(t);
            }),
            (e.prototype.changeState = function (t) {
                this.state && this.state.onExit(),
                    (this.state = t),
                    this.state &&
                        ((this.state.data = this.set引导数据.value), (this.state.context = this), this.state.onEnter());
            }),
            (e.prototype.AddGroup = function (t) {
                t && (t.group = this.group);
            }),
            (e.prototype.RemoveGroup = function (t) {
                t && (t.groupIndex = 0);
            }),
            (e.prototype.hideAll = function () {
                (this.黑色遮罩.active = !1),
                    (this.按钮.active = !1),
                    (this.双倍按钮.active = !1),
                    (this.拖动按钮.active = !1),
                    (this.人物.active = !1),
                    (this.对话框.active = !1),
                    (this.手.active = !1);
            }),
            (e.prototype.on引导数据 = function () {
                var t = this.set引导数据.value;
                0 == t.Type
                    ? this.changeState(new m())
                    : 1 == t.Type
                    ? this.changeState(new _())
                    : 2 == t.Type
                    ? this.changeState(new g())
                    : 3 == t.Type
                    ? this.changeState(new A())
                    : 4 == t.Type
                    ? this.changeState(new v())
                    : 5 == t.Type
                    ? this.changeState(new b())
                    : 6 == t.Type
                    ? this.changeState(new C())
                    : 7 == t.Type && this.changeState(new w());
            }),
            (e.prototype.goNext = function (t) {
                void 0 === t && (t = !1);
                var e = this.set引导数据.value;
                e.IDCanBeEnded &&
                    ((e.IDCanBeEnded + "").includes("99999")
                        ? (a.default.所有已完成的引导.push(99999),
                          (a.default.所有已完成的引导 = a.default.所有已完成的引导))
                        : (a.default.所有已完成的引导.push(e.IDCanBeEnded),
                          (a.default.所有已完成的引导 = a.default.所有已完成的引导)),
                    a.default.setStore(),
                    p.default.platformCtrl.dd(f.dd.GuideComplete, {
                        GuideCompleteID: e.IDCanBeEnded,
                        eventTime: Date.now()
                    }));
                e.zanting && u.default.inst && (u.default.inst.speed.value = 0);
                var o = this.set引导数据.value.NextID;
                t && (o = this.set引导数据.value.failId);
                var n = d.DatasManager.GuideDatasById[o];
                n
                    ? ((this.set引导数据.value = n), n.zanting && u.default.inst && (u.default.inst.speed.value = 1))
                    : (this.changeState(null), this.hideView(), cc.Canvas.instance.node.emit("引导完全结束"));
            }),
            (e.prototype.show手人物对话框黑色遮罩 = function (t) {
                t.haveAHand ? (this.手.active = !0) : (this.手.active = !1),
                    t.haveAConverstation
                        ? ((this.对话框.active = !0),
                          (this.对话框.x = t.converstationOffset[0]),
                          (this.对话框.y = t.converstationOffset[1]),
                          (this.人物.active = !0),
                          (this.人物.x = t.converstationOffset[0]),
                          (this.人物.y = t.converstationOffset[1] + 35),
                          (this.人物.scaleX = t.converstationRotate * this.人物.scaleY),
                          this.人物.scaleX > 0 ? (this.人物.x += 120) : (this.人物.x -= 120),
                          (this.对话框文字.string = t.converstationContext))
                        : ((this.对话框.active = !1), (this.人物.active = !1)),
                    t.haveAMask ? (this.黑色遮罩.active = !0) : (this.黑色遮罩.active = !1);
            }),
            (e.prototype.async按钮位置 = function (t, e) {
                if (t && e) {
                    (t.width = e.width), (t.height = e.height);
                    var o = s.toPos(e, this.view);
                    (t.x = o.x), (t.y = o.y);
                }
            }),
            (e.prototype.async手的位置 = function (t, e) {
                if (this.手.active)
                    if (e) {
                        var o = s.toPos(e, this.view);
                        (this.手.x = o.x + t.handOffset[0]), (this.手.y = o.y + t.handOffset[1]);
                    } else (this.手.x = t.handOffset[0]), (this.手.y = t.handOffset[1]);
            }),
            (e.prototype.emitBtn = function (t) {
                if (t.getComponent(i.default)) t.emit("click");
                else {
                    var e = t.getComponent(cc.Button);
                    cc.Component.EventHandler.emitEvents(e.clickEvents);
                }
            }),
            (e.isRuning = !1),
            e
        );
    })(c.default);
o.default = h;
var y = (function () {
        function t() {}
        return (
            (t.prototype.onEnter = function () {}),
            (t.prototype.onUpdate = function (t) {}),
            (t.prototype.onExit = function () {}),
            (t.prototype.onClick = function (t) {}),
            t
        );
    })(),
    g = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                this.context.hideAll(), this.context.show手人物对话框黑色遮罩(this.data), this.onUpdate();
            }),
            (e.prototype.onClick = function (t) {
                "按钮" == t && (this.context.emitBtn(this.btn), this.context.goNext());
            }),
            (e.prototype.onUpdate = function () {
                this.btn
                    ? (this.context.async按钮位置(this.context.按钮, this.btn),
                      this.context.async手的位置(this.data, this.context.按钮))
                    : ((this.btn = l.getGuideBtn(this.data.Button, this.data.TongMing)),
                      this.btn &&
                          ((this.context.按钮.active = !0),
                          this.context.AddGroup(this.btn),
                          this.context.async按钮位置(this.context.按钮, this.btn),
                          this.context.async手的位置(this.data, this.context.按钮)));
            }),
            (e.prototype.onExit = function () {
                this.context.RemoveGroup(this.btn);
            }),
            e
        );
    })(y),
    v = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                this.context.hideAll(), this.context.show手人物对话框黑色遮罩(this.data), this.onUpdate();
            }),
            (e.prototype.onClick = function (t) {
                var e = this;
                "按钮" == t && (this.context.emitBtn(this.btn), this.context.goNext()),
                    "双倍按钮" == t &&
                        (cc.Canvas.instance.node.once(
                            "看视频成功",
                            function () {
                                e.context.goNext();
                            },
                            this
                        ),
                        this.context.emitBtn(this.video));
            }),
            (e.prototype.onUpdate = function () {
                this.btn
                    ? (this.context.async按钮位置(this.context.按钮, this.btn),
                      this.context.async手的位置(this.data, this.context.按钮))
                    : ((this.btn = l.getGuideBtn(this.data.Button, this.data.TongMing)),
                      this.btn &&
                          ((this.context.按钮.active = !0),
                          this.context.AddGroup(this.btn),
                          this.context.async按钮位置(this.context.按钮, this.btn),
                          this.context.async手的位置(this.data, this.context.按钮))),
                    this.video
                        ? this.context.async按钮位置(this.context.双倍按钮, this.video)
                        : ((this.video = l.getGuideBtn(this.data.videoBtn, this.data.TongMing)),
                          this.video &&
                              ((this.context.双倍按钮.active = !0),
                              this.context.AddGroup(this.video),
                              this.context.async按钮位置(this.context.双倍按钮, this.video)));
            }),
            (e.prototype.onExit = function () {
                this.context.RemoveGroup(this.btn), this.context.RemoveGroup(this.video);
            }),
            e
        );
    })(y),
    m = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                this.context.hideAll(), this.context.show手人物对话框黑色遮罩(this.data);
            }),
            (e.prototype.onUpdate = function () {
                this.context.async手的位置(this.data);
            }),
            (e.prototype.onClick = function (t) {
                "透明背景" == t && this.context.goNext();
            }),
            e
        );
    })(y),
    _ = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                this.context.hideAll(), this.context.show手人物对话框黑色遮罩(this.data);
            }),
            (e.prototype.onUpdate = function () {
                this.node
                    ? this.context.async手的位置(this.data, this.node)
                    : ((this.node = l.getGuideBtn(this.data.Button, this.data.TongMing)),
                      this.node &&
                          (this.context.AddGroup(this.node), this.context.async手的位置(this.data, this.node)));
            }),
            (e.prototype.onClick = function (t) {
                "透明背景" == t && this.context.goNext();
            }),
            (e.prototype.onExit = function () {
                this.context.RemoveGroup(this.node);
            }),
            e
        );
    })(y),
    A = (function (t) {
        function e() {
            var e = (null !== t && t.apply(this, arguments)) || this;
            return (e.progress = 0), (e.time = 0), (e.max = 1), e;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                var t = this;
                this.context.hideAll(), this.context.show手人物对话框黑色遮罩(this.data);
                var e = this.context.拖动按钮;
                e.on(cc.Node.EventType.TOUCH_START, this.onTOUCH_START, this),
                    e.on(cc.Node.EventType.TOUCH_MOVE, this.onTOUCH_MOVE, this),
                    e.on(cc.Node.EventType.TOUCH_END, this.onTOUCH_END, this),
                    e.on(cc.Node.EventType.TOUCH_CANCEL, this.onTOUCH_END, this),
                    (this.手sk = this.context.手.getComponent(sp.Skeleton)),
                    this.手sk.setAnimation(0, "Click", !0),
                    (this.手sk.paused = !0),
                    cc.Canvas.instance.node.once(
                        "零件安装完成",
                        function () {
                            t.context.goNext();
                        },
                        this
                    );
            }),
            (e.prototype.onTOUCH_START = function (t) {
                this.comp.onTOUCH_START(t);
            }),
            (e.prototype.onTOUCH_MOVE = function (t) {
                this.comp.onTOUCH_MOVE(t);
            }),
            (e.prototype.onTOUCH_END = function () {
                this.comp.onTOUCH_END();
            }),
            (e.prototype.onUpdate = function (t) {
                this.node
                    ? (this.context.async按钮位置(this.context.拖动按钮, this.node), this.async手的位置(t))
                    : ((this.node = l.getGuideBtn(this.data.Button, this.data.TongMing)),
                      this.node &&
                          ((this.comp = this.node.getComponent(可拖动)),
                          (this.context.拖动按钮.active = !0),
                          this.context.AddGroup(this.node),
                          (this.sk = cc.find("Canvas/View/仓库/sk")),
                          this.context.AddGroup(this.sk)));
            }),
            (e.prototype.async手的位置 = function (t) {
                (this.time += t),
                    this.time >= this.max && (this.time = this.max),
                    (this.progress = this.time / this.max);
                var e = s.toPos(this.node, this.context.view),
                    o = cc.v2();
                (o.x = e.x + this.data.handOffset[0]), (o.y = e.y + this.data.handOffset[1]);
                var n = cc.v2();
                (n.x = e.x + this.data.ZhongDian[0]),
                    (n.y = e.y + this.data.ZhongDian[1]),
                    (this.context.手.x = o.x + (n.x - o.x) * this.progress),
                    (this.context.手.y = o.y + (n.y - o.y) * this.progress),
                    this.time == this.max && (this.time = 0);
            }),
            (e.prototype.onExit = function () {
                this.context.RemoveGroup(this.node), this.context.RemoveGroup(this.sk);
                var t = this.context.拖动按钮;
                t.off(cc.Node.EventType.TOUCH_START, this.onTOUCH_START, this),
                    t.off(cc.Node.EventType.TOUCH_MOVE, this.onTOUCH_MOVE, this),
                    t.off(cc.Node.EventType.TOUCH_END, this.onTOUCH_END, this),
                    t.off(cc.Node.EventType.TOUCH_CANCEL, this.onTOUCH_END, this),
                    (this.手sk.paused = !1);
            }),
            e
        );
    })(y),
    b = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                var t = this;
                this.context.hideAll(),
                    cc.Canvas.instance.node.once(
                        "战斗回合开始",
                        function () {
                            t.context.goNext();
                        },
                        this
                    );
            }),
            e
        );
    })(y),
    C = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                var t = this;
                this.context.hideAll(),
                    (this.context.透明背景.active = !1),
                    cc.Canvas.instance.node.once("战斗结束", function (e) {
                        e ? t.context.goNext() : t.context.goNext(!0);
                    });
            }),
            (e.prototype.onExit = function () {
                this.context.透明背景.active = !0;
            }),
            e
        );
    })(y),
    w = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                var t = this;
                this.context.hideAll(),
                    (this.context.透明背景.active = !1),
                    cc.Canvas.instance.node.once("客人离开", function () {
                        t.context.goNext();
                    });
            }),
            (e.prototype.onExit = function () {
                this.context.透明背景.active = !0;
            }),
            e
        );
    })(y);
